﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aletfa.LightManager.Effects
{
    public sealed class ArmorEffect : IGameEffect
    {
        /// <summary>
        /// Armatura da applicare
        /// </summary>
        public int Ammount { get; set; }

        /// <summary>
        /// Tipologia di armatura oggetto del buff
        /// </summary>
        public DamageSources Source { get; set; }

        public AlterEffectType Type { get; set; }

        /// <inheritdoc />
        public string Perform(Unit target)
        {
            switch (this.Type)
            {
                case AlterEffectType.Add:
                    target.Armors[this.Source] += this.Ammount;
                    return string.Format("{0} prende +{1} di armatura {2}", target.Name, this.Ammount, (this.Source != DamageSources.Phisical) ? this.Source.ToString() : "");
                case AlterEffectType.Remove:
                    target.Armors[this.Source] -= this.Ammount;
                    if (target.Armors[this.Source] < 0) target.Armors[this.Source] = 0;
                    return string.Format("{0} perde {1} di armatura {2}", target.Name, this.Ammount, (this.Source != DamageSources.Phisical) ? this.Source.ToString() : "");
                case AlterEffectType.Reset:
                    throw new NotImplementedException();
            }
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        public string Undo(Unit target)
        {
            switch (this.Type)
            {
                case AlterEffectType.Add:
                    target.Armors[this.Source] -= this.Ammount;
                    return string.Format("{0} perde {1} di armatura {2}", target.Name, this.Ammount, (this.Source != DamageSources.Phisical) ? this.Source.ToString() : "");
                case AlterEffectType.Remove:
                    target.Armors[this.Source] += this.Ammount;
                    return string.Format("{0} prende +{1} di armatura {2}", target.Name, this.Ammount, (this.Source != DamageSources.Phisical) ? this.Source.ToString() : "");
                case AlterEffectType.Reset:
                    throw new NotImplementedException();
            }
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        public bool IsTemporary { get; set; }

        /// <inheritdoc />
        public bool IsOneShot
        {
            get { return true; }
        }
    }
}
